<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<link rel="Bookmark" href="/favicon.ico" >
<link rel="Shortcut Icon" href="/favicon.ico" />
<!--[if lt IE 9]>
<script type="text/javascript" src="lib/html5shiv.js"></script>
<script type="text/javascript" src="lib/respond.min.js"></script>
<![endif]-->
<link rel="stylesheet" type="text/css" href="static/h-ui/css/H-ui.min.css" />
<link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/H-ui.admin.css" />
<link rel="stylesheet" type="text/css" href="lib/Hui-iconfont/1.0.8/iconfont.css" />
<link rel="stylesheet" type="text/css" href="static/h-ui.admin/skin/default/skin.css" id="skin" />
<link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/style.css" />
<!--[if IE 6]>
<script type="text/javascript" src="lib/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
<title>APP用户管理列表</title>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 系统管理 <span class="c-gray en">&gt;</span> APP用户管理 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
	<div class="text-c"> 日期范围：
		<input type="text" onfocus="WdatePicker({ maxDate:'#F{$dp.$D(\'datemax\')||\'%y-%M-%d\'}' })" id="datemin" class="input-text Wdate" style="width:120px;">
		-
		<input type="text" onfocus="WdatePicker({ minDate:'#F{$dp.$D(\'datemin\')}',maxDate:'%y-%M-%d' })" id="datemax" class="input-text Wdate" style="width:120px;">
		<input type="text" class="input-text" style="width:250px" placeholder="输入姓名" id="userName" name="">
		
		分公司:
		<span class="select-box inline">
		<select class="select" id="comId" name="comId">
			<option value="">请选择分公司</option>
		</select>
		</span>
		票务室:
		<span class="select-box inline">
		<select class="select" id="toId" name="toId">
			<option value="">请选择票务室</option>
		</select>
		</span>
		
		<button type="submit" class="btn btn-success" onClick="queryUserName()" name=""><i class="Hui-iconfont">&#xe665;</i> 搜用户</button>
	</div>
	<div class="cl pd-5 bg-1 bk-gray mt-20"> 
		<span class="l">
			<a href="javascript:;" onclick="datadel()" class="btn btn-danger radius"><i class="Hui-iconfont">&#xe6e2;</i> 批量删除</a>			
			<a href="javascript:;" onclick="muser_add()" class="btn btn-primary radius"><i class="Hui-iconfont">&#xe600;</i> 添加app用户</a>
		</span> 
	</div>
	
	</div>
	<div style="padding: 20px;">
	<table id="divListId" class="table table-border table-bordered table-bg table-hover table-sort">
		<thead>
			<tr class="text-c">
				<th id="thid" style="width: 5px;"><input type="checkbox" style="float:left;"  name="muserid"></th>
				<th >账号</th>
				<th >姓名</th>
				<th >公司</th>
				<th >角色</th>
				<th >所属部门</th>
				<th >注册时间</th>
				<th >审核者</th>
				<th >审核时间</th>
				<th >备注</th>
				<th >状态</th>
				<th >操作</th>
			</tr>
		</thead>
	</table>
	</div>

<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="lib/jquery/1.9.1/jquery.min.js"></script> 
<script type="text/javascript" src="lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="static/h-ui/js/H-ui.min.js"></script> 
<script type="text/javascript" src="static/h-ui.admin/js/H-ui.admin.js"></script>  <!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="lib/My97DatePicker/4.8/WdatePicker.js"></script> 
<script type="text/javascript" src="lib/datatables/1.10.0/jquery.dataTables.min.js"></script> 
<script type="text/javascript" src="lib/laypage/1.2/laypage.js"></script>
<script type="text/javascript" src="js/jquery.base64.js"></script>
<script type="text/javascript">



//var report_service = 'http://cbms.yintn.com:8800/report';
$(document).ready(function(){
	var comId;
	var toId;
	var username =window.localStorage.getItem("user_name");	
	var myArray;
	
		$.ajax({
			type: 'get',
			url: report_service+'/getAllCompany',
			/* beforeSend: function (request) {
							request.setRequestHeader("Authorization", "Bearer " + getToken());
						}, */
			dataType: 'json',
			async: false,
			success: function(data){
				var list =  eval('(' + data.list + ')');
				for(var i = 0;i<list.length;i++){
					$("#comId").append("<option value='"+list[i].companyid+"'>"+list[i].companyname+"</option>");				
				}
			},
			error: function(data){
				console.log(data.msg);
			}
		});
		
		$.ajax({
			type: 'get',
			url: report_service+'/getUserByname',
			data:{
				"username": username
			},
			async: false,
			"bStateSave": true, //状态保存
			/* beforeSend: function (request) {
							request.setRequestHeader("Authorization", "Bearer " + getToken());
						}, */
			dataType: 'json',
			success: function(data){
				var list =  eval('(' + data.list + ')');
				$("#comId").val(list[0].companyId);
				comId = list[0].companyId;
				$.ajax({
					type: 'get',
					url: report_service+'/getTicktOfficeByCom',
					/* beforeSend: function (request) {
									request.setRequestHeader("Authorization", "Bearer " + getToken());
								}, */
					data:{
						"comId":comId
					},
					cache:false,    
					dataType:'json',
					async: false,
					success: function(data){
						//var list = data.list;
						var list =  eval('(' + data.list + ')');
						for(var i=0;i<list.length;i++){
							var option = '<option value="'+list[i].toiid+'">'+list[i].toiname+'</option>';
							$("#toId").append(option);
						}
					},
					error:function(){
						alert("请求失败");
					}
				});
				if(list[0].officeId.indexOf("1")==0){
					$("#toId").val(list[0].officeId);
					toId = list[0].officeId;
					$("#comId").attr("disabled","disabled");
					$("#toId").attr("disabled","disabled");
				}
				if(list[0].officeId.indexOf("1") == -1  && list[0].companyId.indexOf("1")==0 ){
					
					$("#comId").attr("disabled","disabled");
				}
			},
			error: function(data){
				console.log(data.msg);
			}
		});
		
//queryUser();
queryUserName();	


});

	
$("#comId").change(function(){
	$("#toId").empty();
	var comId = $(this).val();
	var targetUrl = report_service+'/getTicktOfficeByCom';
	if(comId == ''){
		//$("#toId").fadeOut("slow");
		return;
	}
	$.ajax({
		type: 'get',
		url: targetUrl,
		/* beforeSend: function (request) {
						request.setRequestHeader("Authorization", "Bearer " + getToken());
					}, */
		data:{
			"comId":comId
		},
		cache:false,    
		dataType:'json',  
		success: function(data){
			//var list = data.list;
			var list =  eval('(' + data.list + ')');
			var option2 = '<option value="">请选择</option>';
			$("#toId").append(option2);
			
			for(var i=0;i<list.length;i++){
				var option = '<option value="'+list[i].toiid+'">'+list[i].toiname+'</option>';
				$("#toId").append(option);
			}
		},
		error:function(){
			alert("请求失败");
		}
	});
});

//var  urls ='apis/muser/'
//var  muser_service = 'http://cbms.yintn.com:8092/';

function admin_add(id){
	var a = id;
	layer_show("审核","a_muser_add.html?id="+a+"",500,300);
}

/* function muser_add(){
	layer_show("新增","a_muser_adduser.html",500,500);
} */
function muser_add(){
	layer_show("新增","a_muser_adduser.html",800,500);
}

function queryUserName(){

	var datemin=document.getElementById("datemin").value;
	var datemax=document.getElementById("datemax").value;
	var userName=document.getElementById("userName").value;
	var comId =  $("#comId").val();
	var officeId =  $("#toId").val();
	
	//$.ajax('apis/muser/muser/getMuserByTimeOrName', {
	$.ajax(muser_service+'muser/getMuserByTimeOrName', {
		data: {
			datemin:datemin,
			datemax:datemax,
			userName:userName,
			comId:comId,
			officeId:officeId
		},
		/* beforeSend: function (request) {
								request.setRequestHeader("Authorization", "Bearer " + getToken());
							}, */
		dataType: 'json',			
		type: 'post',
		//timeout:3000,//超时时间设置为10秒；
		success:function(data){
			$('#divListId').DataTable( {
				   data: data.list,
				   //stateSave: true,
				   "lengthMenu":[10, 50, 100],
				   "pageLength": 100,
				   //使用对象数组，一定要配置columns，告诉 DataTables 每列对应的属性
				   //data 这里是固定不变的，name，position，salary，office 为你数据里对应的属性
				   destroy:true,
				   columns: [
					   { data: 'id' },
					   { data: 'tel' },
					   { data: 'name' },
					   { data: 'company'},
					   { data: 'profession'},
					   { data: 'office' },
					   { data: 'time'},
					   { data: 'auditor' },
					   { data: 'auditorTime' },
					   { data: 'remarks'},
					   { data:  null},
					   { data: null}
					   
				   ],
				  /* aoColumnDefs: [
						 //{"bVisible": false, "aTargets": [ 3 ]} //控制列的隐藏显示
						 {orderable:false,"aTargets":[0]}// 制定列不参与排序
					   ], */
				  columnDefs: [
					 // +'<td><a href="javascript:;" onclick="admin_add(\''+list[i].id+'\')" class="btn btn-primary radius"><i class="Hui-iconfont">&#xe600;</i> 审核</a></td>'
					 {
						"orderable": false,
						 "targets": 0
					 }, {
						 "targets": 0,//
						 "data": null,
						 render: function(data, type, row, meta) {
							return '<input type="checkbox"  value="'+data+'" style="float:center;"name="muserid">'
		
						}
					  } ,
						{
						   "targets": 10,//
						   "data": null,
						   render: function(data, type, row, meta) {
							   if(row.type==0){
								   return '<td>未审核</td>'
							   }else if(row.type==1){
									return '<td>已通过</td>'
							   }else if(row.type==2){
									return '<td>未通过</td>'
							   }else if(row.type==3){
									return '<td>再申请</td>'
							   }else{
								   return '<td></td>'
							   }
											
						   }
						} ,
						{
					   "targets": -1,//最后一列
					   "data": null,
					   render: function(data, type, row, meta) {
						   if(row.type==0 || row.type==3){
							return'<td><a href="javascript:;" onclick="admin_add(\''+data.id+'\')" class="btn btn-primary radius"><i class="Hui-iconfont">&#xe600;</i> 审核</a></td>'
						   }else{
							return'<td></td>'
						   }
						   
						   
					   }
					} ]
			   } );
			document.getElementById("thid").setAttribute("class","");
		},  
		error: function(e) {
			//alert("错误456");
		}
	});
}

function datadel (){

	var chk_value =[];//定义一个数组    
	var ids = "";
	$('input[name="muserid"]:checked').each(function(){//遍历每一个名字为interest的复选框，其中选中的执行函数    
		chk_value.push($(this).val());//将选中的值添加到数组chk_value中   
		ids=ids+$(this).val()+","
	});
	//$.ajax('http://192.168.4.132:8092/muser/delMuerById', {
	//$.ajax('apis/muser/muser/delMuerById',{
	$.ajax(muser_service+'muser/delMuerById',{
		data:{
			"ids":ids
		},
		/* beforeSend: function (request) {
								request.setRequestHeader("Authorization", "Bearer " + getToken());
							}, */
		dataType: 'json',
		type: 'post',
		//timeout:3000,//超时时间设置为10秒；
		success: function(data) {
			window.location.reload()//刷新当前页面.
		},
		error: function(e) {
			alert("删除失败，请重新操作！");
		}
	});
}

function updateByUserId(userId,id,type){
//$.ajax('/apis/muser/muserApply/updateUserApplyById', {
	$.ajax(muser_service+'muserApply/updateUserApplyById', {
		data: {
			"userId":userId,
			"id":id,
			"type":type
		},
		 /* beforeSend: function (request) {
								request.setRequestHeader("Authorization", "Bearer " + getToken());
							}, */
		dataType: 'json',
		type: 'post',
		//timeout:3000,//超时时间设置为10秒；
		success: function(data) {
			if(data.msg==1){
			 document.location.reload();
			}
		},
		error: function(e) {
			//alert("错误456");
		}
	});
}



</script>
</body>
</html>
